package cz.gelion.shylock.invoice.entity

import javax.persistence.Entity
import javax.persistence.Table
import javax.persistence.Id
import javax.persistence.GeneratedValue
import scala.beans.BeanProperty
import javax.persistence.Column
import javax.persistence.ManyToOne
import javax.persistence.JoinColumn
import org.hibernate.mapping.OneToMany


@Entity
@Table(name="subject_contact")
class Contact {
  
  def this(subj:SubjectUnit) = {
    this
    setSubjectUnit(subj)
  }

  @Id
  @GeneratedValue
  @BeanProperty
  @Column(name="id")
  var id:Int = _
  
  @BeanProperty
  @Column(name="addr")
  var addr:String = _
  
  @ManyToOne
  @BeanProperty
  @JoinColumn(name="subject_unit")
  var subjectUnit:SubjectUnit = _
  
  @ManyToOne
  @BeanProperty
  @JoinColumn(name="contact_type")
  var ctype:ContactType = _
  
  
}


@Entity
@Table(name="contact_type")
class ContactType {
    
    @Id
    @BeanProperty
    @Column(name="id")
    var id:String = _
    
    @BeanProperty
    @Column(name="descr")
    var description:String = _
    
  
}